//
//  ScenicSpotCell.m
//  ImGuider
//
//  Created by 王鹏宇 on 2017/4/12.
//  Copyright © 2017年 imguider. All rights reserved.
//

#import "ScenicSpotCell.h"

@interface ScenicSpotCell()

@property (weak, nonatomic) IBOutlet UILabel *ScenicNameLabel;

@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

@property (weak, nonatomic) IBOutlet UILabel *distanceLabel;

@property (weak, nonatomic) IBOutlet UILabel *guiderNumLabel;

@property (weak, nonatomic) IBOutlet UILabel *visitCountLabel;

@property (weak, nonatomic) IBOutlet UIImageView *ScenicImageView;

@end

@implementation ScenicSpotCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.ScenicNameLabel.textColor = kTitleColor;
    self.timeLabel.textColor = kContentColor;
    self.visitCountLabel.textColor = kContentColor;
    self.guiderNumLabel.textColor = kContentColor;
    self.timeLabel.textColor = kContentColor;
    self.distanceLabel.textColor = kContentColor;
}


- (void)configScenicWith:(Scenic *)scenic {
    
    CGFloat distance = [IGUtils getDistanceFromCoordinate:CLLocationCoordinate2DMake(scenic.lat.floatValue, scenic.lng.floatValue) toCoordinate:[LocationManager sharedManager].currentLocation.coordinate];
    distance = distance / 1000.0f;
    if (distance >= 10) {
        self.distanceLabel.text = @">10 km";
    }else if(distance < 0.1){
        self.distanceLabel.text = @"<100 m";
    }else{
        self.distanceLabel.text = [NSString stringWithFormat:@"%0.2f km",distance];
    }
    self.ScenicNameLabel.text = scenic.viewname;
    self.timeLabel.text = scenic.openinfo;
    self.guiderNumLabel.text = [NSString stringWithFormat:@"%@",scenic.guides];
    self.visitCountLabel.text = [NSString stringWithFormat:@"%@",scenic.visit];
    [self.ScenicImageView setImageURL:[NSURL URLWithString:[scenic.pictureArray firstObject]] placeholderImage:[UIImage imageNamed:@"placeholder_squ"]];
    
}

@end
